﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Product.aspx.cs" Inherits="ncp.Web.page.Product" %>
<%@ Import Namespace="ncp.Business" %>
<%@ Register Assembly="ncp.Controls" Namespace="ncp.Controls" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Src="/uc/search.ascx" TagName="search"  TagPrefix="uc" %>
<%@ Register Src="/uc/headTop.ascx" TagName="headTop"  TagPrefix="uc" %>
<%@ Register Src="/uc/headLogo.ascx" TagName="headlogo"  TagPrefix="uc" %>
<%@ Register Src="/uc/menu.ascx" TagName="menu"  TagPrefix="uc" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>中国农业信息化服务商</title>
    <link href="/css/module.css" rel="stylesheet" type="text/css" />
    <link href="/css/page.css" rel="stylesheet" type="text/css" />
    <link href="/css/reset.css" rel="stylesheet" type="text/css" />
    <script src="/js/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="/js/common.js" type="text/javascript"></script>
    <script type="text/javascript">
    	function showImg(obj,c) {
    		var imgSrc=$(obj).attr("src");
    		$(".bh-zzg-cpck-ckdt img").attr("src", imgSrc);
    		$(".bh-zzg-cpck-ckxtcn1 img").removeClass("current");
    		$(obj).addClass("current");
    		current = c;
    			$(".bh-zzg-cpck-ckxtcn1").hide();
    		$(".bh-zzg-cpck-ckxtcn1").eq(current).show();
    		if (current==0) {
    			$(".bh-zzg-cpck-ckxtcn1").eq(current+1).show();
    			$(".bh-zzg-cpck-ckxtcn1").eq(current+2).show();
    		} else if(current==count) {
    			$(".bh-zzg-cpck-ckxtcn1").eq(current-1).show();
    			$(".bh-zzg-cpck-ckxtcn1").eq(current-2).show();
    		} else {
    			$(".bh-zzg-cpck-ckxtcn1").eq(current+1).show();
    			$(".bh-zzg-cpck-ckxtcn1").eq(current-1).show();
    		}
    	}

    	var current = 0, count = 0;
    	function imgPrev() {
    		if (current!=0) {
    			current--;
    			showImg($(".bh-zzg-cpck-ckxtcn1:eq(" + current + ") img"),current);
    		} else {
    			alert('已经是第一张图片！');
    		}
    	}
    	function imgNext() {
    		if (current<count) {
    			current++;
    			if (current<count) {
    				showImg($(".bh-zzg-cpck-ckxtcn1:eq(" + current + ") img"),current);
    				
    			}
    		} else {
    			alert('已经是最后一张图片！');
    			count--;
    		}
    	}

    	$(function() {
    	    getImages();
    	    count = $(".bh-zzg-cpck-ckxtcn img").length;

    	    $(".bh-zzg-cpck-ckxtcn1").each(function(i) {
    	        $(".bh-zzg-cpck-ckxtcn1 img").eq(i).bind("click", function() {
    	            showImg($(".bh-zzg-cpck-ckxtcn1:eq(" + i + ") img"), i);
    	        });
    	    });
    	    showImg($(".bh-zzg-cpck-ckxtcn1:eq(0) img"), 0);
    	    getComment();
    	    getUserInfo();
    	    $("#closeLogin").click(function() {
    	        hideLogin();
    	    });
    	    $("#bottom_login_tips a").click(function() {
    	        showLogin();
    	    });
    	    $("#textAccount,#textPwd,#verifycode").keypress(function(e) {
    	        var key = window.event ? e.keyCode : e.which;
    	        if (key.toString() == "13") {
    	            login();
    	            return false;
    	        }
    	    });
    	});
    	function hideLogin() {
    	    $(".logArea").hide();
    	    $("#bottom_login_tips").removeClass("select");
    	}
    	function showLogin() {
    	    if (!$("#bottom_login_tips").hasClass("select")) {
    	        $("#bottom_login_tips").addClass("select");
    	        $(".logArea").show();
    	    }
    	}
    	//获取留言信息
    	function getComment() {
    	    var proid = '<%=Request.QueryString["id"] %>';
    	    if (proid == "") {
    	        alert("参数错误！");
    	        return;
    	    }
    	    var rep = ncp.Web.page.Product.LoadComment(proid);
    	    if (rep.value != null) {
    	        var jsonOBJ = eval(rep.value)[0];
    	        if (jsonOBJ.isreload) {
    	            $(".bh-zzg-cpck-plnr").html(jsonOBJ.msg);
    	        } else {
    	            alert(jsonOBJ.msg);
    	        }
    	    }
    	}
    	//页面计时器
    	var se, m = 0, h = 0, s = 0, ss = 1;
    	function second() {
    	    if ((ss % 100) == 0) { s += 1; ss = 1; }
    	    if (s > 0 && (s % 60) == 0) { m += 1; }
    	    ss += 1;
    	    if (s>180) {
    	        stopclock();
    	    }
    	}
    	function startclock() { se = setInterval("second()", 1); }
    	function stopclock() { clearInterval(se); ss = 1; m = h = s = 0; }
    	//留言
    	function leaveMessage() {
    	    if (getUserInfo() == "") {
    	        alert("请先登录后再发帖！");
    	        showLogin();
    	        return;
    	    }
    	    if (s!=0) {
    	        alert("留言间隔不能少于3分钟！");
    	        return;
    	    }
    	    var proid = '<%=Request.QueryString["id"] %>';
    	    if (proid == "") {
    	        alert("参数错误！");
    	        return;
    	    }
    	    var ele = new Object();
    	    ele.product_id = proid;
    	    var comment = $("#commentContent").val();
    	    var leng = getByteLen(comment);
    	    if (leng==0) {
    	        alert("留言内容不能为空！");
    	        return;
    	    }
    	    if (leng>160) {
    	        alert("留言长度不能超过160字符！");
    	        return;
    	    }
    	    ele.comment_note = comment;
    	    var rep = ncp.Web.page.Product.LeaveMsg($.objectToJson(ele));
    	    if (rep.value != null) {
    	        var jsonOBJ = eval(rep.value)[0];
    	        if (jsonOBJ.isreload) {
    	            $("#commentContent").val("");
    	            getComment();
    	            startclock();
    	        } else {
    	            alert(jsonOBJ.msg);
    	        }
    	    }
    	}
    	//获取图片信息
    	function getImages() {
    	    var proid = '<%=Request.QueryString["id"] %>';
    	    if (proid == "") {
    	        alert("参数错误！");
    	        return;
    	    }
    	    var rep = ncp.Web.page.Product.GetProductImages(proid);
    	    if (rep.value != null) {
    	        var jsonOBJ = eval(rep.value)[0];
    	        if (jsonOBJ.isreload) {
    	            $("#proImgs").html(jsonOBJ.msg);
    	        } else {
    	            alert(jsonOBJ.msg);
    	        }
    	    }
    	}
    	function onfresh() {
    	    var rand = Math.random() * 1000;
    	    $("#checkImage").attr("src", "/work/VerificationCode.aspx?" + rand);
    	}
    	function getUserInfo() {
    	    var response = ncp.Web.page.Product.GetUserInfo();
    	    if (response.value != null) {
    	        var jsonOBJ = eval(response.value)[0];
    	        if (jsonOBJ.msg!="") {
    	            $("#bottom_login_tips").html(jsonOBJ.msg);
    	        } else {
    	        $("#bottom_login_tips").html("<a href=\"javascript:void(0)\" style=\"font-weight:bold\">登录</a>(请登录发言，并遵守相关规定)");
    	            $("#bottom_login_tips a").click(function() {
    	                showLogin();
    	            });
    	        }
    	        return jsonOBJ.msg;
    	    }
    	    return "";
    	}
    	
    	function login() {
    	    var username = $.trim($("#textAccount").val());
    	    var pwd = $("#textPwd").val();
    	    var verifycode = $("#verifycode").val();
    	    if (username == "") {
    	        alert("用户名不能为空！");
    	        $("#textAccount").focus();
    	        return;
    	    }
    	    if (pwd == "") {
    	        alert("密码不能为空！");
    	        $("#textPwd").focus();
    	        return;
    	    }
    	    if (verifycode == "") {
    	        alert("验证码不能为空！");
    	        $("#verifycode").focus();
    	        return;
    	    }
    	    var rep = ncp.Web.page.Product.VerificationCode(verifycode);
    	    if (rep.value != null) {
    	        var jsonOBJ = eval(rep.value)[0];
    	        if (!jsonOBJ.isreload) {
    	            alert("验证码错误");
    	            onfresh();
    	            return;
    	        }
    	        var response = ncp.Web.page.Product.UserLogin(username, pwd);
    	        if (response.value != "") {
    	            var jsonOBJ = eval(response.value)[0];
    	            if (jsonOBJ.isreload) {
    	                getUserInfo();
    	                userStatues();
    	                $("#textAccount,#textPwd,#verifycode").val("");
    	                hideLogin();
    	            } else
    	                alert(jsonOBJ.msg);
    	        }
    	    }
    	}
    	function onLoginOut() {
    	    $.ajax({
    	        url: "/handler/LogoutHandler.ashx",
    	        type: "POST",
    	        dataType: "text",
    	        success: function() {
    	        getUserInfo();
    	        userStatues();
    	        }
    	    });
    	}
    </script>
    </head>
<body>
    <form id="form1" runat="server">
     <!--Head Begin--> 
<!--Head Top-->
<uc:headTop id="headtop" runat="server" />
<!--Head Logo-->
<uc:headlogo id="headlogo" runat="server" />
<!--Head Nav-->
<div id="head-nav">
	<div id="head-nav-center">
	    <uc:menu ID="menu" runat="server"/>
        <uc:search id="search" runat="server" />
    </div>
</div>
<!--Head End-->
<div class="bh-space"></div>
<div class="wp">
  <div class="bh-zzg-cpck-center">
    <div class="bh-zzg-cpck-left bh-fl">
      <!--广告位-->
      <div id="ad10_2" class="bh-zzg-cpck-ggw"><img src='/image/private/pic-11.jpg' width='214' height='146' /></div>
      <div id="ad10_3" class="bh-zzg-cpck-ggw"><img src='/image/private/pic-11.jpg' width='214' height='146' /></div>
      <div id="ad10_4" class="bh-zzg-cpck-ggw"><img src='/image/private/pic-11.jpg' width='214' height='146' /></div>
      <div id="ad10_5" class="bh-zzg-cpck-ggw"><img src='/image/private/pic-11.jpg' width='214' height='146' /></div>
      <div id="ad10_6" class="bh-zzg-cpck-ggw"><img src='/image/private/pic-11.jpg' width='214' height='146' /></div>
      <div id="ad10_7" class="bh-zzg-cpck-ggw"><img src='/image/private/pic-11.jpg' width='214' height='146' /></div>
      <div id="ad10_8" class="bh-zzg-cpck-ggw"><img src='/image/private/pic-11.jpg' width='214' height='146' /></div>
    </div>
    <div class="bh-zzg-cpck-right bh-fr">
      <div class="bh-zzg-cpck-ck">
          
        <div class="bh-zzg-cpck-ckt bh-fl">
          <div class="bh-zzg-cpck-ckdt"> <img src="../image/private/product/bh-zzg-cpck-ckdt.jpg" /> </div>
          <div class="bh-zzg-cpck-ckxt">
            <div class="bh-zzg-cpck-ckxtl bh-fl"><a href="javascript:void(0)" onclick="imgPrev();"><img src="/image/bh-zzg-cpck-ckdtL.jpg" /></a></div>
            <div class="bh-zzg-cpck-ckxtc bh-fl">
              <div id="proImgs" class="bh-zzg-cpck-ckxtcn">
              </div>
            </div>
            <div class="bh-zzg-cpck-ckxtl bh-fr"><a href="javascript:void(0)" onclick="imgNext();"><img src="/image/bh-zzg-cpck-ckdtR.jpg" /></a></div>
            <div class="bh-clear"></div>
          </div>
        </div>
        
        <div class="bh-zzg-cpck-ckz bh-fr">
          <div class="bh-zzg-cpck-ckz1">
            <ul>
              <li><span>产品分类</span>
                <p>
                    <asp:Literal ID="lbType" runat="server"></asp:Literal>
                </p>
              </li>
              <li><span>产品名称</span>
                <p><asp:Literal ID="lbName" runat="server" Text=""></asp:Literal></p>
              </li>
              <li><span>产品数量</span>
                <p><asp:Literal ID="lbNum" runat="server" Text=""></asp:Literal></p>
              </li>
              <li><span>发布时间</span>
                <p><asp:Literal ID="lbStart" runat="server" Text=""></asp:Literal></p>
              </li>
              <li><span>有效期</span>
                <p><asp:Literal ID="lbEnd" runat="server" Text=""></asp:Literal></p>
              </li>
              
            </ul>
          </div>
          <div class="bh-zzg-cpck-ckz2">
            <ul>
              <li><span>公司(名字)/个人</span>
                <p><asp:Literal ID="lbUserName" runat="server"></asp:Literal></p>
              </li>
              <li><span>联系人</span>
                <p><asp:Literal ID="lbContact" runat="server"></asp:Literal></p>
              </li>
              <li><span>手机</span>
                <p><asp:Literal ID="lbCellPhone" runat="server"></asp:Literal></p>
              </li>
              <li><span>固话</span>
                <p><asp:Literal ID="lbTelPhone" runat="server"></asp:Literal></p>
              </li>
              <li><span>邮箱</span>
                <p><asp:Literal ID="lbEmail" runat="server"></asp:Literal></p>
              </li>
              <li><span>地址</span>
                <p><asp:Literal ID="lbAddr" runat="server"></asp:Literal></p>
              </li>
              <li><span>用户店铺</span>
                <p><a href="/shop<%=GetShopId() %>/product.html">进入用户店铺</a></p>
              </li>
            </ul>
          </div>
        </div>
        <div class="bh-clear"></div>
      </div>
      <div class="bh-zzg-cpck-xqxx">
        <div class="bh-zzg-cpck-xqxxbt">
          <h2>详情信息</h2>
        </div>
        <div class="bh-zzg-cpck-xqxxbr">
          <div class="bh-zzg-cpck-xqxxbrp">
              <asp:Literal ID="ltIntro" runat="server"></asp:Literal>
          </div>
        </div>
      </div>
      <div class="bh-zzg-cpck-vip">
        <div class="bh-zzg-cpck-vipbt">
          <h2>VIP用户同类产品</h2>
        </div>
        <div class="bh-zzg-cpck-vipnr">
          <div class="bh-zzg-cpck-vipnr1">
            
              <asp:Repeater ID="repSame" runat="server">
                  <ItemTemplate>
                    <dl>
                      <dt><a href="/product/<%#EncryptHelper.EncryptString(Eval("Product_Id").ToString())%>"><img src="<%#Eval("Product_Picture") %>" /></a></dt>
                      <dd><a href="/product/<%#EncryptHelper.EncryptString(Eval("Product_Id").ToString())%>"><%#Eval("Product_Title")%></a></dd>
                    </dl>  
                  </ItemTemplate>
              </asp:Repeater>
            <div class="bh-clear"></div>
          </div>
        </div>
      </div>
      <div class="bh-zzg-cpck-pl">
        <div class="bh-zzg-cpck-pl1">
          <div class="bh-zzg-cpck-plbt">
            <h2>评论</h2>
          </div>
          <div class="bh-zzg-cpck-plnr">
          </div>
        </div>
        <div class="bh-zzg-cpck-pl2">
          <textarea id="commentContent" class="bh-zzg-cpck-pl2textarea"></textarea>
        </div>
        <div class="form">
            <span class="left">
                <em id="bottom_login_tips" style="display: block; ">
                    <a href="javascript:void(0)" style="font-weight:bold">登录</a>
                    (请登录发言，并遵守相关规定)
                </em>
            </span>
            <div class="right">
                <input type="button" onclick="leaveMessage()" value="确认留言" class="bh-zzg-cpck-qrly" />
                <input type="reset" value="取消" class="bh-zzg-cpck-qx" />
            </div>
            <div class="logArea">
                <div id="login_list">
                    <div id="closeLogin"></div>
                    <div style="clear: both">
                        <ul>
                            <li>
                                <span>用户名</span>
                                <input style=" width:170px" id="textAccount" name="user_name" type="text" >
                            </li>
                            <li>
                                <span>密&nbsp;&nbsp;码</span>
                                <input style="width:170px" id="textPwd" name="password" type="password">
                            </li>
                            <li><span>验证码</span><input style="width:170px" id="verifycode" name="verifycode" type="text" maxlength="4"></li>
                            <li>
                                <span></span>
                                <img id="checkImage" src="/work/VerificationCode.aspx" width="93" height="25"  alt="验证码"　title="验证码" />
      <label><a href="javascript:void(0)" onclick="onfresh()">看不清，换一张</a></label>
                            </li>
                            <li>
                                <span></span>
                                <input type="button" onclick="login()" value="登 录" class="bh-zzg-cpck-qrly" />
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
          
        </div>
      </div>
    </div>
    <div class="bh-clear"></div>
  </div>
</div>
<div class="bh-space"></div>
<!--Foot Begin-->
<!--#include file="/uc/footer.htm"-->
<!--Foot End-->
    </form>
</body>
</html>
<script type="text/javascript">

    $(function() {
        var response = ncp.Web.page.Product.GetADList();
        if (response.value != null) {
            var jsonOBJ = eval(response.value)[0];
            $("#ad10_2").html(jsonOBJ.ad10_2);
            $("#ad10_3").html(jsonOBJ.ad10_3);
            $("#ad10_4").html(jsonOBJ.ad10_4);
            $("#ad10_5").html(jsonOBJ.ad10_5);
            $("#ad10_6").html(jsonOBJ.ad10_6);
            $("#ad10_7").html(jsonOBJ.ad10_7);
            $("#ad10_8").html(jsonOBJ.ad10_8);
        }
    });
</script>